<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Marketing_card extends MY_Controller {

	/**
	 * Index Page for this controller.
	 *
	 */
	public function index($status = -1,$limit = 0)
	{
		//获取学习卡
		$this->load->model('School_learn_card_model');
		$card_list = $this->School_learn_card_model->get_learn_card($this->user_data['school_id'],$limit,$this->offset,$status);
		$this->smarty->assign("card_list", $card_list['result']);

		$this->load->library('pagination');
		$page_config['base_url'] = '/marketing_card/index/'.$status;
		$page_config['total_rows'] = $card_list['total_count'];
		$page_config['per_page'] = $this->offset ;
		$page_config['uri_segment'] = 4;
		$this->pagination->initialize($page_config);
		$pagination = $this->pagination->create_links();

		$this->smarty->assign("pagination", $pagination);

		$this->smarty->assign("menu", "marketing");
		$this->smarty->display("marketing/marketing_card.html");
	}

	function add(){
		$post_data = $this->input->post();
		if($post_data){
			$this->load->model('School_learn_card_model');
			$result = $this->School_learn_card_model->generate_learn_card($post_data,$this->user_data['school_id']);
			header("Location:/marketing_card");exit;
		}

		//获取视频课
		$this->load->model('Courseo2o_model');
		$course = $this->Courseo2o_model->get_course_all_by_school($this->user_data['school_id'],1,1);
		$this->smarty->assign("course", $course);

		//获取题库
		$this->smarty->assign("tiku",  array());
		//获取实训
		$this->smarty->assign("shixun", array());


		$this->smarty->assign("menu", "marketing");
		$this->smarty->display("marketing/marketing_card_add.html");
	}
}
